package com.luochen.cdpt.repository;

import com.luochen.cdpt.eneity.InsuranceCompany;
import com.luochen.cdpt.eneity.QInsuranceCompany;
import com.querydsl.core.types.dsl.StringPath;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer;
import org.springframework.data.querydsl.binding.QuerydslBindings;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

/**
 * @Auther: star
 * @Date: 2019/1/23 11:20
 * @Description:
 */
@RepositoryRestResource(path = "/inscompany")
public interface InsCompanyRepository extends PagingAndSortingRepository<InsuranceCompany,String>,
        QuerydslPredicateExecutor<InsuranceCompany>, JpaSpecificationExecutor<InsuranceCompany>, QuerydslBinderCustomizer<QInsuranceCompany> {

    default void customize(QuerydslBindings bindings, QInsuranceCompany qInsuranceCompany) {
        bindings.bind(qInsuranceCompany.name,qInsuranceCompany.code).first(
                (StringPath path, String value) -> path.contains(value));
    }
}
